package com.poly.polyarr;

public class PolyArray {
    public static void main(String[] args) {
        Person[] persons = new Person[5];
        persons[0] = new Person("Jack" , 20);
        persons[1] = new Student("Lily" , 23, 100);
        persons[2] = new Student("John" , 25, 200);
        persons[3] = new Teacher("King" , 45, 15000);
        persons[4] = new Teacher("Wang" , 20, 24000);

        for (Person i : persons) {
            System.out.println(i.Say());
            if (i instanceof Student) {
                ((Student) i).Study();
            } else if (i instanceof Teacher) {
                ((Teacher) i).Teach();
            } else if (i instanceof Person) {

            } else {
                System.out.println("类型错误，请检查");
            }


        }

    }
}
